#define _CRT_SECURE_NO_WARNINGS 1
#include<stdio.h>
int is_leap(int year)
{
	return year % 4 == 0 && year % 100 != 0 || year % 400 == 0;
}
int main()
{
	int LeapDay[13] = { 0,31,29,31,30,31,30,31,31,30,31,30,31 };
	int CommonDay[13] = { 0,31,28,31,30,31,30,31,31,30,31,30,31 };
	int year = 0;
	int month = 0;
	while (scanf("%d%d", &year, &month) == 2)
	{
		if (is_leap(year))
		{
			printf("%d\n", LeapDay[month]);
		}
		else
		{
			printf("%d\n", CommonDay[month]);
		}
	}
}